﻿using Cookbook.Models;
using Cookbook.Services;
using Microsoft.Practices.Prism.StoreApps;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cookbook.ViewModels
{
    public class RecipesViewModel : ViewModel
    {
        private ObservableCollection<Recipe> recipes;

        public ObservableCollection<Recipe> Recipes
        {
            get { return recipes; }
            set { this.SetProperty(ref this.recipes, value); }
        }        

        public RecipesViewModel()
        {
            this.Recipes = new ObservableCollection<Recipe>();
        }

        public async Task LoadRecipes()
        {
            var recipes = await RecipeService.GetRecipes();
            this.Recipes = new ObservableCollection<Recipe>(recipes);
        }
    }
}
